﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Jzy.Core.Common.Basic;
using Jzy.Core.Utility;
using Jzy.Core.Dict;
using ECommerce.Common;
using ECommerce.BLL.Product;
using ECommerce.Model.Product;

namespace ECommerce.Web.Site
{
    public partial class Comment : SitePage
    {
        private ECProductCommentBO ECComment
        {
            get
            {
                return ECProductCommentBO.Instance<ECProductCommentBO>();
            }
        }

        private string ProductID
        {
            get
            {
                return Request.QueryString["ProductID"];
            }
        }


        protected void Page_Load(object sender, EventArgs e)
        {
            if (SitePage.IsTimeout())
            {
                string script = "alert('访问超时，请重新登录');top.location.href='" + GlobalVar.WebAppPath + "/site/login.aspx';";
                //JSUtil.ResponseJS(script);
            }
            if (!IsPostBack)
            {
                DictBO dict = new DictBO();
                dict.BindListControl(drpPrice, (int)DictItem.价格评价);
                dict.BindListControl(drpTaste, (int)DictItem.口味评价);
                dict.BindListControl(drpSculpt, (int)DictItem.造型评价);


            }
        }

        protected void btnSave_Click(object sender, EventArgs e)
        {
            ECProductCommentInfo info = ECComment.GetInfo(int.Parse(ProductID), SiteSession.MemberID);
            info.InputTime = DateTime.Now;
            info.Price = drpPrice.SelectedItem.Text;
            info.MemberID = SiteSession.MemberID;
            info.MemberLoginName = SiteSession.MemberLoginName;
            info.IsDisplay = true;
            info.ProductID = int.Parse(ProductID);
            info.Sculpt = drpSculpt.SelectedItem.Text;
            info.Taste = drpTaste.SelectedItem.Text;
            info.Content = txtContent.Text.Replace("<","&lt;");
            info.Score = int.Parse(hidScore.Value);

            ECComment.Save(info);

            string script = "alert('评价成功');top.delDivFrm();";
            JSUtil.ResponseJS(script);
        }
    }
}